﻿using AgileDevTool.Helpers;
using System.Windows.Controls;
using System.Windows.Input;

namespace AgileDevTool.UserControls
{
    /// <summary>
    /// ProjectItemUserControl.xaml 的交互逻辑
    /// </summary>
    public partial class ProjectItemUserControl : UserControl
    {
        public delegate void ProjectItemClickedEventHandler(string path);

        public event ProjectItemClickedEventHandler ProjectItemClicked;

        public ProjectItemUserControl(ProjectItem item)
        {
            InitializeComponent();
            tbk_Name.Text = item.Name;
            tbk_Path.Text = item.Path;
            var LastOpenedAt = "";
            if (item.LastOpenedAt.HasValue)
            {
                LastOpenedAt="上次打开："+item.LastOpenedAt.GetValueOrDefault().ToString("yyyy/MM/dd HH:mm:ss");
            }
            tbk_LastOpendedAt.Text = LastOpenedAt;
            key = item.Path;
        }

        private readonly string key;

        private void Border_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            ProjectItemClicked(key);
        }
    }
}
